## creating figure 2-9 with the multivariate model
# model: multivariate model based on demographics, logit specification, DV: Q11 dummy variable

demo_mod <- svyglm(Q11_d ~ dem + rep + ideo3 + male + white + black + hispanic + asian + income5 +
                     EDUC5 + unemployed + silent + boomer + genx + millen + activeduty + vet +
                     social + family + midwest + south + west + catholic + christian + norelig +
                     city + rural + married + A2 + A3 + A4 + A5 + A6 + A7 + A8,
                   family = binomial(link = "logit"),
                   design = w2_design)

#### RELIGION ####

catho <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1), 
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = 1, 
                    christian = 0, 
                    norelig = 0,
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
catho.pred <- as.data.frame(predict(demo_mod, newdata = catho, type = "response", se.fit = TRUE))

chstn <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1), 
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1), 
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = 0, 
                    christian = 1, 
                    norelig = 0,
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
chstn.pred <- as.data.frame(predict(demo_mod, newdata = chstn, type = "response", se.fit = TRUE))

other <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1), 
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1), 
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = 0, 
                    christian = 0, 
                    norelig = 0,
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
other.pred <- as.data.frame(predict(demo_mod, newdata = other, type = "response", se.fit = TRUE))

norel <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1), 
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1), 
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = 0, 
                    christian = 0, 
                    norelig = 1,
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
norel.pred <- as.data.frame(predict(demo_mod, newdata = norel, type = "response", se.fit = TRUE))

relig.pred <- rbind(catho.pred, chstn.pred, other.pred, norel.pred)
name <- c("Christian", "Catholic", "Other", "None")
V1 <- c(rep(9,4))
relig.pred <- cbind(V1, name, relig.pred)

#### RACE ####

white <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1), 
                    white = 1, 
                    black = 0, 
                    hispanic = 0, 
                    asian = 0,
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
white.pred <- as.data.frame(predict(demo_mod, newdata = white, type = "response", se.fit = TRUE))

black <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1), 
                    white = 0, 
                    black = 1, 
                    hispanic = 0, 
                    asian = 0,
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
black.pred <- as.data.frame(predict(demo_mod, newdata = black, type = "response", se.fit = TRUE))

hispn <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),
                    white = 0,
                    black = 0, 
                    hispanic = 1, 
                    asian = 0,
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
hispn.pred <- as.data.frame(predict(demo_mod, newdata = hispn, type = "response", se.fit = TRUE))

asian <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1), 
                    white = 0, 
                    black = 0, 
                    hispanic = 0, 
                    asian = 1,
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
asian.pred <- as.data.frame(predict(demo_mod, newdata = asian, type = "response", se.fit = TRUE))

race.pred <- rbind(white.pred, black.pred, hispn.pred, asian.pred)
name <- c("White", "Black", "Hispanic", "Asian")
V1 <- c(rep(8,4))
race.pred <- cbind(V1, name, race.pred)

#### EDUCATION ####

educ <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 5), 
                   rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 5), 
                   ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                   male = rep(svymean(~ male, w2_design, na.rm = TRUE), 5),
                   white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                   black = rep(svymean(~ black, w2_design, na.rm = TRUE), 5), 
                   hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 5), 
                   asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 5),
                   income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 5), 
                   EDUC5 = c(1:5), 
                   unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 5),
                   silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                   boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 5), 
                   genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 5), 
                   millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 5),
                   activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 5), 
                   vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 5), 
                   social = rep(svymean(~ social, w2_design, na.rm = TRUE), 5), 
                   family = rep(svymean(~ family, w2_design, na.rm = TRUE), 5),
                   midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 5), 
                   south = rep(svymean(~ south, w2_design, na.rm = TRUE), 5), 
                   west = rep(svymean(~ west, w2_design, na.rm = TRUE), 5),
                   catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 5), 
                   christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 5), 
                   norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 5),
                   city = rep(svymean(~ city, w2_design, na.rm = TRUE), 5), 
                   rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 5), 
                   married = rep(svymean(~ married, w2_design, na.rm = TRUE), 5),
                   A2 = rep(0, 5),
                   A3 = rep(0, 5),
                   A4 = rep(0, 5),
                   A5 = rep(0, 5),
                   A6 = rep(0, 5),
                   A7 = rep(0, 5),
                   A8 = rep(0, 5))
educ.pred <- as.data.frame(predict(demo_mod, newdata = educ, type = "response", se.fit = TRUE))
name <- c("Less than HS", "HS", "Some college", "College", "Graduate")
V1 <- c(rep(7,5))
educ.pred <- cbind(V1, name, educ.pred)

#### GENERATION ####

silnt <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1), 
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1), 
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = 1,
                    boomer = 0, 
                    genx = 0, 
                    millen = 0,
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
silnt.pred <- as.data.frame(predict(demo_mod, newdata = silnt, type = "response", se.fit = TRUE))

boomr <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1), 
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1), 
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = 0,
                    boomer = 1, 
                    genx = 0, 
                    millen = 0,
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
boomr.pred <- as.data.frame(predict(demo_mod, newdata = boomr, type = "response", se.fit = TRUE))

genx <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                   rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                   ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                   male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                   white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                   black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                   hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                   asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                   income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                   EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                   unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                   silent = 0,
                   boomer = 0, 
                   genx = 1, 
                   millen = 0,
                   activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                   vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                   social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                   family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                   midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                   south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                   west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                   catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                   christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                   norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                   city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                   rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                   married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                   A2 = 0,
                   A3 = 0,
                   A4 = 0,
                   A5 = 0,
                   A6 = 0,
                   A7 = 0,
                   A8 = 0)
genx.pred <- as.data.frame(predict(demo_mod, newdata = genx, type = "response", se.fit = TRUE))

millen <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                     rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                     ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                     male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1), 
                     white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1), 
                     black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                     hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                     asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                     income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                     EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                     unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                     silent = 0,
                     boomer = 0, 
                     genx = 0, 
                     millen = 1,
                     activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                     vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                     social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                     family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                     midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                     south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                     west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                     catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                     christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                     norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                     city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                     rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                     married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                     A2 = 0,
                     A3 = 0,
                     A4 = 0,
                     A5 = 0,
                     A6 = 0,
                     A7 = 0,
                     A8 = 0)
millen.pred <- as.data.frame(predict(demo_mod, newdata = millen, type = "response", se.fit = TRUE))

genz <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                   rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                   ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                   male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1), 
                   white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1), 
                   black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                   hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                   asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                   income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                   EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                   unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                   silent = 0,
                   boomer = 0, 
                   genx = 0, 
                   millen = 0,
                   activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                   vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                   social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                   family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                   midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                   south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                   west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                   catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                   christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                   norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                   city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                   rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                   married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                   A2 = 0,
                   A3 = 0,
                   A4 = 0,
                   A5 = 0,
                   A6 = 0,
                   A7 = 0,
                   A8 = 0)
genz.pred <- as.data.frame(predict(demo_mod, newdata = genz, type = "response", se.fit = TRUE))

gener.pred <- rbind(silnt.pred, boomr.pred, genx.pred, millen.pred, genz.pred)
name <- c("Silent", "Boomer", "Gen X", "Millennial", "Gen Z")
V1 <- c(rep(6,5))
gener.pred <- cbind(V1, name, gener.pred)

#### REGION ####

north <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1), 
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1), 
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = 0, 
                    south = 0, 
                    west = 0,
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
north.pred <- as.data.frame(predict(demo_mod, newdata = north, type = "response", se.fit = TRUE))

mwest <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1), 
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1), 
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = 1, 
                    south = 0, 
                    west = 0,
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
mwest.pred <- as.data.frame(predict(demo_mod, newdata = mwest, type = "response", se.fit = TRUE))

south <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1), 
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1), 
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = 0, 
                    south = 1, 
                    west = 0,
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
south.pred <- as.data.frame(predict(demo_mod, newdata = south, type = "response", se.fit = TRUE))

west <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                   rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                   ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                   male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1), 
                   white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1), 
                   black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                   hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                   asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                   income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                   EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                   unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                   silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                   boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                   genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                   millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                   activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                   vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                   social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                   family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                   midwest = 0, 
                   south = 0, 
                   west = 1,
                   catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                   christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                   norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                   city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                   rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                   married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                   A2 = 0,
                   A3 = 0,
                   A4 = 0,
                   A5 = 0,
                   A6 = 0,
                   A7 = 0,
                   A8 = 0)
west.pred <- as.data.frame(predict(demo_mod, newdata = west, type = "response", se.fit = TRUE))

region.pred <- rbind(north.pred, mwest.pred, south.pred, west.pred)
name <- c("Northeast", "Midwest", "South", "West")
V1 <- c(rep(5,4))
region.pred <- cbind(V1, name, region.pred)

#### GEOGRAPHY ####

urban <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1), 
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1), 
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = 1, 
                    rural = 0, 
                    married = rep(svymean(~ married, w2_design, type = "response", na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
urban.pred <- as.data.frame(predict(demo_mod, newdata = urban, type = "response", se.fit = TRUE))

subrb <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = 0, 
                    rural = 0, 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
subrb.pred <- as.data.frame(predict(demo_mod, newdata = subrb, type = "response", se.fit = TRUE))

rural <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = 0, 
                    rural = 1, 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
rural.pred <- as.data.frame(predict(demo_mod, newdata = rural, type = "response", se.fit = TRUE))

geog.pred <- rbind(urban.pred, subrb.pred, rural.pred)
name <- c("Urban", "Suburban", "Rural")
V1 <- c(rep(4,3))
geog.pred <- cbind(V1, name, geog.pred)

#### EMPLOYMENT ####

yempl <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = 0,
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
yempl.pred <- as.data.frame(predict(demo_mod, newdata = yempl, type = "response", se.fit = TRUE))

nempl <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = 1,
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
nempl.pred <- as.data.frame(predict(demo_mod, newdata = nempl, type = "response", se.fit = TRUE))

employ.pred <- rbind(yempl.pred, nempl.pred)
name <- c("Employed", "Unemployed")
V1 <- c(rep(3,2))
employ.pred <- cbind(V1, name, employ.pred)

#### INCOME ####

incom <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 5), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 5), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 5),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 5),  
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 5), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 5), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 5),
                    income5 = c(1:5), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 5), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 5),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 5), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 5), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 5),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 5), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 5), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 5), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 5),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 5), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 5), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 5),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 5), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 5), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 5),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 5), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 5), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 5),
                    A2 = rep(0,5),
                    A3 = rep(0,5),
                    A4 = rep(0,5),
                    A5 = rep(0,5),
                    A6 = rep(0,5),
                    A7 = rep(0,5),
                    A8 = rep(0,5))
incom.pred <- as.data.frame(predict(demo_mod, newdata = incom, type = "response", se.fit = TRUE))
name <- c("Q5", "Q4", "Q3", "Q2", "Q1")
V1 <- c(rep(2,5))
incom.pred <- cbind(V1, name, incom.pred)

#### PARTY ID ####

dem <- data.frame(dem = 1, 
                  rep = 0, 
                  ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                  male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                  white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                  black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                  hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                  asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                  income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                  EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                  unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                  silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                  boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                  genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                  millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                  activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                  vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                  social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                  family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                  midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                  south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                  west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                  catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                  christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                  norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                  city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                  rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                  married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                  A2 = 0,
                  A3 = 0,
                  A4 = 0,
                  A5 = 0,
                  A6 = 0,
                  A7 = 0,
                  A8 = 0)
dem.pred <- as.data.frame(predict(demo_mod, newdata = dem, type = "response", se.fit = TRUE))

ind <- data.frame(dem = 0, 
                  rep = 0, 
                  ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                  male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                  white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                  black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                  hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                  asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                  income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                  EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                  unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                  silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                  boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                  genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                  millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                  activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                  vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                  social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                  family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                  midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                  south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                  west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                  catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                  christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                  norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                  city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                  rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                  married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                  A2 = 0,
                  A3 = 0,
                  A4 = 0,
                  A5 = 0,
                  A6 = 0,
                  A7 = 0,
                  A8 = 0)
ind.pred <- as.data.frame(predict(demo_mod, newdata = ind, type = "response", se.fit = TRUE))

rep <- data.frame(dem = 0, 
                  rep = 1, 
                  ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                  male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                  white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                  black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                  hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                  asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                  income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                  EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                  unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                  silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                  boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                  genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                  millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                  activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                  vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                  social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                  family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                  midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                  south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                  west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                  catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                  christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                  norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                  city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                  rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                  married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                  A2 = 0,
                  A3 = 0,
                  A4 = 0,
                  A5 = 0,
                  A6 = 0,
                  A7 = 0,
                  A8 = 0)
rep.pred <- as.data.frame(predict(demo_mod, newdata = rep, type = "response", se.fit = TRUE))

party.pred <- rbind(dem.pred, ind.pred, rep.pred)
name <- c("Democrat", "Independent", "Republican")
V1 <- c(rep(15,3))
party.pred <- cbind(V1, name, party.pred)

#### IDEOLOGY ####

lib <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                  rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                  ideo3 = 0,
                  male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                  white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                  black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                  hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                  asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                  income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                  EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                  unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                  silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                  boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                  genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                  millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                  activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                  vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                  social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                  family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                  midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                  south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                  west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                  catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                  christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                  norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                  city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                  rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                  married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                  A2 = 0,
                  A3 = 0,
                  A4 = 0,
                  A5 = 0,
                  A6 = 0,
                  A7 = 0,
                  A8 = 0)
lib.pred <- as.data.frame(predict(demo_mod, newdata = lib, type = "response", se.fit = TRUE))

mod <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                  rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                  ideo3 = 1,
                  male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                  white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                  black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                  hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                  asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                  income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                  EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                  unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                  silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                  boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                  genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                  millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                  activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                  vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                  social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                  family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                  midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                  south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                  west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                  catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                  christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                  norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                  city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                  rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                  married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                  A2 = 0,
                  A3 = 0,
                  A4 = 0,
                  A5 = 0,
                  A6 = 0,
                  A7 = 0,
                  A8 = 0)
mod.pred <- as.data.frame(predict(demo_mod, newdata = mod, type = "response", se.fit = TRUE))

con <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                  rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                  ideo3 = 2,
                  male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                  white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                  black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                  hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                  asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                  income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                  EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                  unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                  silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                  boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                  genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                  millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                  activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                  vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                  social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                  family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                  midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                  south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                  west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                  catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                  christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                  norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                  city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                  rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                  married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                  A2 = 0,
                  A3 = 0,
                  A4 = 0,
                  A5 = 0,
                  A6 = 0,
                  A7 = 0,
                  A8 = 0)
con.pred <- as.data.frame(predict(demo_mod, newdata = con, type = "response", se.fit = TRUE))

ideom.pred <- rbind(lib.pred, mod.pred, con.pred)
name <- c("Liberal", "Moderate", "Conservative")
V1 <- c(rep(14,3))
ideom.pred <- cbind(V1, name, ideom.pred)

#### GENDER ####

female <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                     rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                     ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                     male = 0,  
                     white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                     black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                     hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                     asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                     income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                     EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                     unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                     silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                     boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                     genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                     millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                     activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                     vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                     social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                     family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                     midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                     south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                     west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                     catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                     christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                     norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                     city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                     rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                     married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                     A2 = 0,
                     A3 = 0,
                     A4 = 0,
                     A5 = 0,
                     A6 = 0,
                     A7 = 0,
                     A8 = 0)
female.pred <- as.data.frame(predict(demo_mod, newdata = female, type = "response", se.fit = TRUE))

male <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                   rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                   ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                   male = 1,  
                   white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                   black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                   hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                   asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                   income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                   EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                   unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                   silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                   boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                   genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                   millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                   activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                   vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                   social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                   family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                   midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                   south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                   west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                   catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                   christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                   norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                   city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                   rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                   married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                   A2 = 0,
                   A3 = 0,
                   A4 = 0,
                   A5 = 0,
                   A6 = 0,
                   A7 = 0,
                   A8 = 0)
male.pred <- as.data.frame(predict(demo_mod, newdata = male, type = "response", se.fit = TRUE))

gender.pred <- rbind(female.pred, male.pred)
name <- c("Female", "Male")
V1 <- c(rep(13,2))
gender.pred <- cbind(V1, name, gender.pred)

#### VETERAN STATUS ####

active <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                     rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                     ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                     male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                     white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                     black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                     hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                     asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                     income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                     EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                     unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                     silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                     boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                     genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                     millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                     activeduty = 1, 
                     vet = 0, 
                     social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                     family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                     midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                     south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                     west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                     catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                     christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                     norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                     city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                     rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                     married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                     A2 = 0,
                     A3 = 0,
                     A4 = 0,
                     A5 = 0,
                     A6 = 0,
                     A7 = 0,
                     A8 = 0)
active.pred <- as.data.frame(predict(demo_mod, newdata = active, type = "response", se.fit = TRUE))

vetrn <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = 0, 
                    vet = 1, 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
vetrn.pred <- as.data.frame(predict(demo_mod, newdata = vetrn, type = "response", se.fit = TRUE))

civil <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = 0, 
                    vet = 0, 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
civil.pred <- as.data.frame(predict(demo_mod, newdata = civil, type = "response", se.fit = TRUE))

vet.pred <- rbind(active.pred, vetrn.pred, civil.pred)
name <- c("Active Duty", "Veteran", "Civilian")
V1 <- c(rep(12,3))
vet.pred <- cbind(V1, name, vet.pred)

#### FAMILY CONTACT ####

nfami <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = 0,
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
nfami.pred <- as.data.frame(predict(demo_mod, newdata = nfami, type = "response", se.fit = TRUE))

yfami <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = 1,
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
yfami.pred <- as.data.frame(predict(demo_mod, newdata = yfami, type = "response", se.fit = TRUE))

family.pred <- rbind(nfami.pred, yfami.pred)
name <- c("No", "Yes")
V1 <- c(rep(11,2))
family.pred <- cbind(V1, name, family.pred)

#### SOCIAL CONTACT ####

nsoco <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = 0, 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
nsoco.pred <- as.data.frame(predict(demo_mod, newdata = nsoco, type = "response", se.fit = TRUE))

ysoco <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = 1, 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = rep(svymean(~ married, w2_design, na.rm = TRUE), 1),
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
ysoco.pred <- as.data.frame(predict(demo_mod, newdata = ysoco, type = "response", se.fit = TRUE))

social.pred <- rbind(nsoco.pred, ysoco.pred)
name <- c("No", "Yes")
V1 <- c(rep(10,2))
social.pred <- cbind(V1, name, social.pred)

#### MARITAL STATUS ####

nmari <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1), 
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1), 
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = 0,
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
nmari.pred <- as.data.frame(predict(demo_mod, newdata = nmari, type = "response", se.fit = TRUE))

ymari <- data.frame(dem = rep(svymean(~ dem, w2_design, na.rm = TRUE), 1), 
                    rep = rep(svymean(~ rep, w2_design, na.rm = TRUE), 1), 
                    ideo3 = rep(svymean(~ ideo3, w2_design, na.rm = TRUE), 1),
                    male = rep(svymean(~ male, w2_design, na.rm = TRUE), 1),  
                    white = rep(svymean(~ white, w2_design, na.rm = TRUE), 1),
                    black = rep(svymean(~ black, w2_design, na.rm = TRUE), 1), 
                    hispanic = rep(svymean(~ hispanic, w2_design, na.rm = TRUE), 1), 
                    asian = rep(svymean(~ asian, w2_design, na.rm = TRUE), 1),
                    income5 = rep(svymean(~ income5, w2_design, na.rm = TRUE), 1), 
                    EDUC5 = rep(svymean(~ EDUC5, w2_design, na.rm = TRUE), 1), 
                    unemployed = rep(svymean(~ unemployed, w2_design, na.rm = TRUE), 1),
                    silent = rep(svymean(~ silent, w2_design, na.rm = TRUE), 1),
                    boomer = rep(svymean(~ boomer, w2_design, na.rm = TRUE), 1), 
                    genx = rep(svymean(~ genx, w2_design, na.rm = TRUE), 1), 
                    millen = rep(svymean(~ millen, w2_design, na.rm = TRUE), 1),
                    activeduty = rep(svymean(~ activeduty, w2_design, na.rm = TRUE), 1), 
                    vet = rep(svymean(~ vet, w2_design, na.rm = TRUE), 1), 
                    social = rep(svymean(~ social, w2_design, na.rm = TRUE), 1), 
                    family = rep(svymean(~ family, w2_design, na.rm = TRUE), 1),
                    midwest = rep(svymean(~ midwest, w2_design, na.rm = TRUE), 1), 
                    south = rep(svymean(~ south, w2_design, na.rm = TRUE), 1), 
                    west = rep(svymean(~ west, w2_design, na.rm = TRUE), 1),
                    catholic = rep(svymean(~ catholic, w2_design, na.rm = TRUE), 1), 
                    christian = rep(svymean(~ christian, w2_design, na.rm = TRUE), 1), 
                    norelig = rep(svymean(~ norelig, w2_design, na.rm = TRUE), 1),
                    city = rep(svymean(~ city, w2_design, na.rm = TRUE), 1), 
                    rural = rep(svymean(~ rural, w2_design, na.rm = TRUE), 1), 
                    married = 1,
                    A2 = 0,
                    A3 = 0,
                    A4 = 0,
                    A5 = 0,
                    A6 = 0,
                    A7 = 0,
                    A8 = 0)
ymari.pred <- as.data.frame(predict(demo_mod, newdata = ymari, type = "response", se.fit = TRUE))

married.pred <- rbind(nmari.pred, ymari.pred)
name <- c("Single", "Married")
V1 <- c(rep(1,2))
married.pred <- cbind(V1, name, married.pred)

#### FULL DATA FRAME ####

full_data <- as.data.frame(rbind(relig.pred, race.pred, educ.pred, gener.pred,
                                 region.pred, geog.pred, employ.pred, incom.pred,
                                 party.pred, ideom.pred, gender.pred, vet.pred,
                                 family.pred, social.pred, married.pred))
full_data$ci_lo <- full_data$response - 1.96 * full_data$SE
full_data$ci_hi <- full_data$response + 1.96 * full_data$SE
full_data$link <- full_data$response * 100 # make percentages
full_data$ci_lo <- full_data$ci_lo * 100
full_data$ci_hi <- full_data$ci_hi * 100

#### PLOT ####

fig2_9 <- ggplot(full_data, aes(y = link, x = V1, ymin = ci_lo, ymax = ci_hi, 
                                label = name)) + 
  geom_linerange(colour = "gray65") +
  geom_point() + 
  geom_text_repel(size = 2.5, direction = "x", vjust = -1.3) +
  scale_x_continuous(breaks = c(1:15),
                     labels = c("Marital Status", "Income", "Employment", "Geography",
                                "Region", "Generation", "Education", "Race", "Religion",
                                "Social Contact", "Family Contact", "Veteran Status",
                                "Gender", "Ideology", "Party ID")) +
  coord_flip() + xlab("") + ylab("Predicted Support for the Military (%)") + 
  ylim(40,100) + theme_bw()
fig2_9
ggsave("~/Dropbox/Public_Conf_Mil/Chapter 2 Figures/fig2-9_final.jpeg", plot = fig2_9, dpi = 700)
